const ls = window && window.localStorage

const zBlogKey = (key: string) => `${key}`

export const getItem = (key: string) => {
  return JSON.parse(ls.getItem(zBlogKey(key))!)
}

export const setItem = (key: string, val: any) => {
  ls.setItem(zBlogKey(key), JSON.stringify(val))
}

export const clear = () => {
  ls.clear()
}

export const keys = (index: number) => {
  return ls.key(index)
}

export const removeItem = (key: string) => {
  ls.removeItem(zBlogKey(key))
}
